package com.agou.app.admin.business.main.action;

import java.io.IOException;
import java.sql.SQLException;

import com.agou.app.AppContext;
import com.agou.app.admin.business.menu.vo.AdminMenuVo;
import com.agou.app.admin.business.user.action.UserAction;
import com.agou.core.ss.SSException;
import com.agou.core.ss.SSTrace;
import com.agou.ssh.core.base.ActionResultSet;
import com.agou.ssh.core.base.BOResultSet;

public class MainAction extends IMainAction {
	private static final long serialVersionUID = 3887409595343385331L;
	private static SSTrace ssTrace = SSTrace.getInstance(MainAction.class);

	public String main() throws SSException, SQLException, IOException {
		AppContext acx = this.getAppContext();
		ssTrace.debug("main", "用户【#0】进入框架页面，表单参数是【#1】", acx.userLoginId, mainVo);
		ActionResultSet actionResult = new ActionResultSet(UserAction.class);
		try {
			// 设置是否使用事务（不使用事务）
			this.jdbcBeging(false, false);
			this.getAdminMenuBo().setJdbcSession(this.getJdbcSession());
			// 取得所有的导航信息
			AdminMenuVo adminVo = new AdminMenuVo();
			adminVo.setNaviId(mainVo.getNaviId());
			BOResultSet naviBoResult = this.getAdminMenuBo().queryMenuNavi(adminVo);
			if (naviBoResult.IsSuccess == false) {
				actionResult.IsSuccess = false;
				actionResult.ReturnInfo = naviBoResult.ReturnInfo;
			}
			actionResult.addBoResultSet("navi_bo", naviBoResult);
			actionResult.addDataMap("navi_id", mainVo.getNaviId());// 选择的ID
			return "main";// 登陆成功
		} finally {
			this.setActionResultSet(actionResult);
			this.destroy();//
		}
	}

	public String leftTree() throws SSException, SQLException, IOException {
		ActionResultSet actionResult = new ActionResultSet(UserAction.class);
		ssTrace.debug("main", "菜单处理[#0][#1]", mainVo,this.get_());
		try {
			// 设置是否使用事务（不使用事务）
			this.jdbcBeging(false, false);
			this.getAdminMenuBo().setJdbcSession(this.getJdbcSession());
			// 取得所有的导航信息
			AdminMenuVo adminVo = new AdminMenuVo();
			adminVo.setNaviId(mainVo.getNaviId());
			BOResultSet naviBoResult = this.getAdminMenuBo().queryMenu(adminVo);
			if (naviBoResult.IsSuccess == false) {
				actionResult.IsSuccess = false;
				actionResult.ReturnInfo = naviBoResult.ReturnInfo;
			}
			actionResult.addBoResultSet("menu_bo", naviBoResult);
			actionResult.addDataMap("navi_id", mainVo.getNaviId());// 选择的ID
			return "left_tree";// 
		} finally {
			this.setActionResultSet(actionResult);
			this.destroy();//
		}
	}
}
